//
//  LBCReadListCell.m
//  Moment
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LBCReadListCell.h"

@interface LBCReadListCell ()

@property (nonatomic, retain)UILabel *nameLabel;
@property (nonatomic, retain)UIImageView *headImageView;
@property (nonatomic, retain)UILabel *enNaemLabel;
@property (nonatomic, retain)UILabel *titleLabel;

@end

@implementation LBCReadListCell


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    _headImageView = [UIImageView new];
    _headImageView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_headImageView];
    [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(@0);
        
    }];
    
    UIImageView *imageView = [UIImageView new];
    imageView.backgroundColor = [UIColor colorWithRed:0.02 green:0.02 blue:0.03 alpha:0.6];
    [self.contentView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(@0);
        make.height.equalTo(_headImageView.mas_height).multipliedBy(0.2);
        
    }];
    
    _nameLabel = [UILabel new];
    _nameLabel.font = [UIFont systemFontOfSize:16];
    [_nameLabel setTextColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1]];
    [self.contentView addSubview:_nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@5);
        make.bottom.mas_equalTo(@-4);
        make.top.equalTo(imageView.mas_top).offset(5);
        
    }];
    
    _enNaemLabel = [UILabel new];
    _enNaemLabel.font = [UIFont systemFontOfSize:11];
    [_enNaemLabel setTextColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1]];
    [self.contentView addSubview:_enNaemLabel];
    [_enNaemLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nameLabel.mas_right).offset(2);
        make.top.equalTo(_nameLabel.mas_top).offset(3);
        make.height.equalTo(_nameLabel.mas_height).multipliedBy(0.9);
        make.right.equalTo(imageView.mas_right).offset(-5);
        
    }];
    
    
    
}


-(void)setReadListCell:(LBCReadList *)readListCell{
        _readListCell = readListCell;
    [_headImageView sd_setImageWithURL:[NSURL URLWithString:self.readListCell.coverimg] placeholderImage:[UIImage imageNamed:ImagePlaceHolder]];
    _nameLabel.text = self.readListCell.name;
    // 计算文字大小
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16]};
    CGFloat length = [_nameLabel.text boundingRectWithSize:CGSizeMake(320, 2000) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size.width;
    [_nameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(length);
        
    }];
    _enNaemLabel.text = self.readListCell.enname;
    
}





@end
